from constant import *


class PlantMessage:
    def __init__(self, name: str, plant_property: str, other_property: str, price: int, hp: int,card, card_path: list[str],
                 plant, plant_path: str):
        self.name = name
        self.card = card
        self.card_path = card_path
        self.price = price
        self.hp = hp
        self.plant = plant
        self.plant_path = plant_path
        self.property = plant_property
        self.other_property = other_property


class PlantObject(GifObject):
    def __init__(self, screen: pg.Surface, plant: PlantMessage, row, column):
        super().__init__(screen, plant.plant_path, coordinate=(LAWN_START_X + column * LAWN_WIDTH, LAWN_START_Y + row * LAWN_HEIGHT))
        self.property = plant.property
        self.other_property = plant.other_property
        self.row = 0
        self.column = 0
        self.price = plant.price
        self.hp = plant.hp
        self.now_hp = plant.hp
        self.over = False

    def update(self):
        if self.now_hp == 0:
            self.over = True
        hp_sur = pg.Surface((80, 30))
        self.screen.blit(self.state[self.frame_number], self.coordinate)
        self.screen.blit(hp_sur, (self.coordinate[0], self.coordinate[1] - 30))
        self.frame_number = self.frame_number + 1 if self.frame_number < self.state_cycle - 1 else 0


class Peashooter(PlantObject):
    def __init__(self, screen: pg.Surface, row, column):
        self.plant = PlantMessage('Peashooter', 'grassland', 'alone', 100, 100, None,
                                  ['images\\Card\\Plants\\Peashooter1.png', 'images\\Card\\Plants\\Peashooter2.png'],
                                  Peashooter, 'images\\Plants\\Peashooter\\Peashooter.gif')
        super().__init__(screen, self.plant, row, column)




